﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using SqlDataAccess;

namespace QuanLyBanHang.HeThong
{
	public partial class F101_Trang_chu : Form
	{
		public F101_Trang_chu()
		{
			InitializeComponent();
		}

		#region Public Interfaces
		public void display_for_user_group(decimal ip_dc_id_user_group)
		{
			//load danh sach menu theo user_group
			using (BKIQuanLyBanHangEntities db = new BKIQuanLyBanHangEntities())
			{
				List<HT_PHAN_QUYEN_NHOM> lst_ht_phan_quyen = db.HT_PHAN_QUYEN_NHOM
					.Where(x => x.ID_NHOM_NGUOI_DUNG == ip_dc_id_user_group)
					.ToList();
				//Kiem tra tat ca menu item 
				foreach (ToolStripMenuItem control in m_menu.Items)
				{
					//if (control.GetType().Name.Equals(typeof(ToolStripMenuItem)))
					//{
					//Nếu Nhóm người dùng không có quyền (menu) này thì ẩn nó đi
					if (lst_ht_phan_quyen.Count(x => x.HT_CHUC_NANG.MA_CHUC_NANG == control.Name) == 0)
					{
						control.Visible = false;
					}
					else
					{
						control.Visible = true;
					}
					//}
				}
			}

			//Hien thi form Trang chu
			this.ShowDialog();
		}
		#endregion

        #region Member
        BKIQuanLyBanHangEntities db = new BKIQuanLyBanHangEntities();
        #endregion

        #region Private Methods
		#endregion

		#region Events
		private void DanhSachChucNang_Click(object sender, EventArgs e)
		{
			F110_Danh_sach_chuc_nang v_frm = new F110_Danh_sach_chuc_nang();
			v_frm.ShowDialog();
		}

		private void DanhSachNhomNguoiDung_Click(object sender, EventArgs e)
		{
			F120_Danh_sach_nhom_nguoi_dung v_frm = new F120_Danh_sach_nhom_nguoi_dung();
			v_frm.ShowDialog();
		}

		private void PhanQuyenChoNhomNguoiDung_Click(object sender, EventArgs e)
		{
			F130_Phan_quyen_cho_nhom v_frm = new F130_Phan_quyen_cho_nhom();
			v_frm.ShowDialog();
		}

		private void DanhSachNguoiSuDung_Click(object sender, EventArgs e)
		{
			F140_Danh_sach_nguoi_su_dung v_frm = new F140_Danh_sach_nguoi_su_dung();
			v_frm.ShowDialog();
		}

        private void DanhMucNhanVien_Click(object sender, EventArgs e)
        {
            QuanLyBanHang.DanhMuc.F351_Danh_sach_nhan_vien v_frm = new DanhMuc.F351_Danh_sach_nhan_vien();
            v_frm.ShowDialog();
        }

		private void DanhMucSanPham_Click(object sender, EventArgs e)
		{
			F501_Danh_muc_san_pham v_frm = new F501_Danh_muc_san_pham();
			v_frm.ShowDialog();
		}

        private void DanhMucKhachHang_Click(object sender, EventArgs e)
        {
            QuanLyBanHang.DanhMuc.F400_Danh_muc_khach_hang v_frm = new DanhMuc.F400_Danh_muc_khach_hang();
            v_frm.ShowDialog();
        }

		private void DanhMucHoaDonBan_Click(object sender, EventArgs e)
		{
			QuanLyBanHang.GiaoDich.F220_Hoa_don_ban v_frm = new GiaoDich.F220_Hoa_don_ban();
			v_frm.ShowDialog();
		}

		private void DanhMucHoaDonNhap_Click(object sender, EventArgs e)
		{
			QuanLyBanHang.GiaoDich.F210_Hoa_don_nhap v_frm = new GiaoDich.F210_Hoa_don_nhap();
			v_frm.ShowDialog();
		}

		private void GiaoDichNhapSoDuDau_Click(object sender, EventArgs e)
		{

			QuanLyBanHang.GiaoDich.F200_Nhap_so_du_ban_dau v_frm = new GiaoDich.F200_Nhap_so_du_ban_dau();
			v_frm.ShowDialog();
		}

		private void GiaoDichHoaDonNhap_Click(object sender, EventArgs e)
		{
			QuanLyBanHang.GiaoDich.F210_Hoa_don_nhap v_frm = new GiaoDich.F210_Hoa_don_nhap();
			v_frm.ShowDialog();
		}

		private void GiaoDichHoaDonBan_Click(object sender, EventArgs e)
		{
			try
			{
				QuanLyBanHang.GiaoDich.F220_Hoa_don_ban v_frm = new GiaoDich.F220_Hoa_don_ban();
				v_frm.Show();
			}
			catch (Exception v_e)
			{
				MessageBox.Show(v_e.ToString());
			}
		}

		private void BaoCaoSoDuTaiMotThoiDiem_Click(object sender, EventArgs e)
		{
			F910_Bao_cao_so_du_tai_mot_thoi_diem v_frm = new F910_Bao_cao_so_du_tai_mot_thoi_diem();
			v_frm.ShowDialog();
		}

		private void BaoCaoThongKeSanPhamBanChay_Click(object sender, EventArgs e)
		{
			F930_Thong_ke_san_pham_ban_chay v_frm = new F930_Thong_ke_san_pham_ban_chay();
			v_frm.ShowDialog();
		}

		private void BaoCaoThongKeLoiNhuanTheoSanPham_Click(object sender, EventArgs e)
		{
			F940_Thong_ke_loi_nhuan_theo_san_pham v_frm = new F940_Thong_ke_loi_nhuan_theo_san_pham();
			v_frm.ShowDialog();
		}

		private void DanhMucLoaiSanPham_Click(object sender, EventArgs e)
		{
			F500_Danh_muc_loai_san_pham v_frm = new F500_Danh_muc_loai_san_pham();
			v_frm.ShowDialog();
		}

		private void SoDuTheoLoaiSanPham_Click(object sender, EventArgs e)
		{
			QuanLyBanHang.BaoCao.F901_Bao_cao_so_du_theo_san_pham v_frm = new BaoCao.F901_Bao_cao_so_du_theo_san_pham();
			v_frm.ShowDialog();
		}

		private void BaoCaoDoanhThuTheoKhachHang_Click(object sender, EventArgs e)
		{
			F950_Bao_cao_doanh_thu_theo_khach_hang v_frm = new F950_Bao_cao_doanh_thu_theo_khach_hang();
			v_frm.ShowDialog();
		}

		private void BaoCaoThongKeKhachHangNo_Click(object sender, EventArgs e)
		{
			F960_Thong_ke_khach_hang_no v_frm = new F960_Thong_ke_khach_hang_no();
			v_frm.ShowDialog();
		}

		private void BaoCaoThongKeLuongNhanVien_Click(object sender, EventArgs e)
		{
			F920_Bao_cao_luong_nhan_vien v_frm = new F920_Bao_cao_luong_nhan_vien();
			v_frm.ShowDialog();
		}

		private void BaoCaoThongKeNoNhaCungCap_Click(object sender, EventArgs e)
		{
			QuanLyBanHang.BaoCao.F970_Thong_ke_no_nha_cung_cap v_frm = new BaoCao.F970_Thong_ke_no_nha_cung_cap();
			v_frm.ShowDialog();
		}

		private void BaoCaoThongKeDoanhThuTheoNhanVien_Click(object sender, EventArgs e)
		{
			QuanLyBanHang.BaoCao.F980_Thong_ke_doanh_thu_theo_nhan_vien v_frm = new BaoCao.F980_Thong_ke_doanh_thu_theo_nhan_vien();
			v_frm.ShowDialog();
		}

        private void TroGiup_Click(object sender, EventArgs e)
        {

        }

        private void DanhMucNhaCungCap_Click(object sender, EventArgs e)
        {
            F300_Danh_muc_nha_cung_cap v_frm = new F300_Danh_muc_nha_cung_cap();
            v_frm.ShowDialog();
        }

        private void grb_ban_hang_Enter(object sender, EventArgs e)
        {
            
        }

        private void m_llb_hoa_don_ban_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            QuanLyBanHang.GiaoDich.F220_Hoa_don_ban v_frm = new GiaoDich.F220_Hoa_don_ban();
            v_frm.ShowDialog();
        }

        private void F101_Trang_chu_Load(object sender, EventArgs e)
        {
            try
            {
                decimal v_dc_id_nhan_vien = QuanLyBanHang.HeThong.DangNhap.getIDUser();
                HT_NGUOI_SU_DUNG v_nhan_vien = db.HT_NGUOI_SU_DUNG.FirstOrDefault(x => x.ID == v_dc_id_nhan_vien);
                m_lbl_dang_nhap_quyen.Text = "Người sử dụng " + v_nhan_vien.HO_TEN_NHAN_VIEN + "-" + v_nhan_vien.MA_NHAN_VIEN;
            }
            catch (Exception v_e)
            {
                MessageBox.Show(v_e.ToString());
            }
        }
       
        private void m_llb_dm_ncc_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            F810_Tra_cuu_danh_muc_nha_cung_cap v_frm = new F810_Tra_cuu_danh_muc_nha_cung_cap();
            v_frm.ShowDialog();
        }

        private void m_llb_dm_san_pham_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            F800_Tra_cuu_danh_muc_san_pham v_frm = new F800_Tra_cuu_danh_muc_san_pham();
            v_frm.ShowDialog();
        }

        private void TraCuuNhanVien_Click(object sender, EventArgs e)
        {
            F820_Tra_cuu_nhan_vien v_frm = new F820_Tra_cuu_nhan_vien();
            v_frm.ShowDialog();
        }

        private void GioiThieu_Click(object sender, EventArgs e)
        {
            QuanLyBanHang.Helper.F999_Gioi_thieu v_frm = new Helper.F999_Gioi_thieu();
            v_frm.ShowDialog();
        }

        private void m_llb_hoa_don_nhap_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            QuanLyBanHang.GiaoDich.F210_Hoa_don_nhap v_frm = new GiaoDich.F210_Hoa_don_nhap();
            v_frm.ShowDialog();
        }

        private void TraCuuDanhMucSanPham_Click(object sender, EventArgs e)
        {
            F800_Tra_cuu_danh_muc_san_pham v_frm = new F800_Tra_cuu_danh_muc_san_pham();
            v_frm.ShowDialog();
        }

        private void TraCuuDanhMucNCC_Click(object sender, EventArgs e)
        {
            F810_Tra_cuu_danh_muc_nha_cung_cap v_frm = new F810_Tra_cuu_danh_muc_nha_cung_cap();
            v_frm.ShowDialog();
        }

        private void TraCuuDanhMucLoaiSanPham_Click(object sender, EventArgs e)
        {
            F830_Tra_cuu_danh_muc_loai_san_pham v_frm = new F830_Tra_cuu_danh_muc_loai_san_pham();
            v_frm.ShowDialog();
        }

        private void m_llb_dm_loai_san_pham_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            F830_Tra_cuu_danh_muc_loai_san_pham v_frm = new F830_Tra_cuu_danh_muc_loai_san_pham();
            v_frm.ShowDialog();
        }

        private void m_llb_dm_nhan_vien_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            F820_Tra_cuu_nhan_vien v_frm = new F820_Tra_cuu_nhan_vien();
            v_frm.ShowDialog();
        }

        private void TraCuuKhachHang_Click(object sender, EventArgs e)
        {
            F820_Tra_cuu_danh_muc_nha_khach_hang v_frm = new F820_Tra_cuu_danh_muc_nha_khach_hang();
            v_frm.ShowDialog();
        }

        private void m_llb_dm_khach_hang_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            F820_Tra_cuu_danh_muc_nha_khach_hang v_frm = new F820_Tra_cuu_danh_muc_nha_khach_hang();
            v_frm.ShowDialog();
        }

        private void SoDuTaiMotThoiDiem_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            F910_Bao_cao_so_du_tai_mot_thoi_diem v_frm = new F910_Bao_cao_so_du_tai_mot_thoi_diem();
            v_frm.ShowDialog();
        }

        private void LoiNhuanTheoSanPham_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            F940_Thong_ke_loi_nhuan_theo_san_pham v_frm = new F940_Thong_ke_loi_nhuan_theo_san_pham();
            v_frm.ShowDialog();
        }

        private void SanPhamBanChay_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            F930_Thong_ke_san_pham_ban_chay v_frm = new F930_Thong_ke_san_pham_ban_chay();
            v_frm.ShowDialog();
        }

        private void NoNCC_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            QuanLyBanHang.BaoCao.F970_Thong_ke_no_nha_cung_cap v_frm = new BaoCao.F970_Thong_ke_no_nha_cung_cap();
            v_frm.ShowDialog();
        }

        private void KhachHangNo_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            F960_Thong_ke_khach_hang_no v_frm = new F960_Thong_ke_khach_hang_no();
            v_frm.ShowDialog();
        }

        private void QuanLyCongNo_Click(object sender, EventArgs e)
        {
            QuanLyBanHang.Giao_dịch.F240_Quan_ly_cong_no v_frm = new Giao_dịch.F240_Quan_ly_cong_no();
            v_frm.ShowDialog();
        }

        private void Thoat_Click(object sender, EventArgs e)
        {
            try
            {
                this.Close();
            }
            catch (Exception v_e)
            {
                MessageBox.Show(v_e.ToString());
            }
        }
        #endregion

        
    }
}
